package net.apexes.demo.codegen.ormlite.column;

import net.apexes.commons.ormlite.Column;
import net.apexes.commons.ormlite.ForeignKey;
import net.apexes.commons.ormlite.Index;
import net.apexes.demo.codegen.ormlite.column.base.QEntityBase;
import net.apexes.demo.codegen.ormlite.entity.GoodsBase;

/**
 * QGoodsBase is a ORMLite query type for GoodsBase
 * @see GoodsBase
 */
public class QGoodsBase extends QEntityBase<GoodsBase> {

    public static final QGoodsBase $ = new QGoodsBase("GOODS_BASE");

    public final Column name = field("name").columnName("NAME").varchar(32).notNull().build();

    public final Column quickCode = field("quickCode").columnName("QUICK_CODE").varchar(8).notNull().build();

    public final Column measureType = field("measureType").columnName("MEASURE_TYPE").varchar(1).notNull().build();

    public final Column goodsGroupId = field("goodsGroupId").columnName("GOODS_GROUP_ID").varchar(22).notNull().build();

    public final Column templateId = field("templateId").columnName("TEMPLATE_ID").varchar(22).notNull().build();

    public class Indexs {

        public final Index constraintIndex30 = index("CONSTRAINT_INDEX_30").column(goodsGroupId).build();

        public final Index ixGoodsBaseStatusGroup = index("IX_GOODS_BASE_STATUS_GROUP").column(statusFlag).column(goodsGroupId, true).build();

        public final Index primaryKey30 = index("PRIMARY_KEY_30").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraint301 = foreignKey(goodsGroupId, "GOODS_GROUP", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QGoodsBase(String tableName) {
        super(GoodsBase.class, tableName);
    }

    @Override
    public GoodsBase newInstance() {
        return new GoodsBase();
    }

    @Override
    public Object getFieldValue(GoodsBase instance, String fieldName) {
        switch (fieldName) {
            case "name":
                return instance.getName();
            case "quickCode":
                return instance.getQuickCode();
            case "measureType":
                return instance.getMeasureType();
            case "goodsGroupId":
                return instance.getGoodsGroupId();
            case "templateId":
                return instance.getTemplateId();
            default:
                return super.getFieldValue(instance, fieldName);
        }
    }

    @Override
    public void setupFieldValue(GoodsBase instance, String fieldName, Object value) {
        switch (fieldName) {
            case "name":
                instance.setName((java.lang.String) value);
                break;
            case "quickCode":
                instance.setQuickCode((java.lang.String) value);
                break;
            case "measureType":
                instance.setMeasureType((java.lang.String) value);
                break;
            case "goodsGroupId":
                instance.setGoodsGroupId((java.lang.String) value);
                break;
            case "templateId":
                instance.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setupFieldValue(instance, fieldName, value);
                break;
        }
    }

}

